import React from 'react';
import { inject, observer } from 'mobx-react';
import { Tools } from 'weaver-mobile';
import { Link, withRouter, Route } from 'react-router-dom';
import { transQueryParams } from '../../util/common';
import allStore from './../../stores'

const getLabel = Tools.getLabel;


@inject('wfContinuationProcessStore')
@withRouter
@observer
class Main extends React.Component {
    constructor(props) {
        super(props);
    }

    componentDidMount(){
        const {wfContinuationProcessStore, location = {}} = this.props;
        const queryParams = transQueryParams(location);
        const {requestUrl, initContinnuationProcessInfo, showRequestPage} = wfContinuationProcessStore;
        const {currentRequestid} = queryParams;
        initContinnuationProcessInfo({currentRequestId : currentRequestid});
      }

    render() {
        const {wfContinuationProcessStore} = this.props;
        const {currentIndex, counts, switchRequest, requestPageLoaded} = wfContinuationProcessStore;
        let spanLabel = getLabel(517273, "第{current}条（共{counts}条）");
        spanLabel = spanLabel.replace(/{current}/, currentIndex + 1);
        spanLabel = spanLabel.replace(/{counts}/, counts);
        return (
            <div className='wf-continuationProcess-div'>
                <div className="wf-continuationProcess-title">
                <span>{spanLabel}</span>
                  <div className="wf-continuationProcess-title-pageSwitch">
                  <span className={(currentIndex != 0 && requestPageLoaded) ? "prePage" : "pre-disabled"} onClick={() => {switchRequest('pre')}}>{getLabel(515115, "上一条")}</span>
                  <span className={(currentIndex != counts - 1 && requestPageLoaded) ? "nextPage" : "disabled"} onClick={() => {switchRequest('next')}}>{getLabel(515116, "下一条")}</span>
                  </div>
                </div>
                <iframe
                  className='wf-continuationProcess-title-formIframe'
                  id="formIframe"
                  // src={""}
                />
            </div>
          )
    }
}

export default Main;